home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
pushpath.arc
/
POPPATH.ASM
next >
Wrap
Assembly Source File
|
1987-02-28
|
4KB
|
97 lines
;Pops the path that PUSHPATH.ASM left in e:\path.dat.
;D. Seidman, 2/28/87
cseg segment para public 'code'
popp proc far
assume cs:cseg, ds:cseg, es:cseg, ss:cseg
org 100H ;for com file
begin: jmp start
file db 'C:\PATH.DAT',0
output db 0
order db 'PATH='
string db 128 dup (0DH)
start: mov sp, offset stk ;move stack in
mov ah,4ah ;make room for command.com
mov bx,400h ;leave 16 k
int 21h
;open the path stack file
mov ah, 3DH ;function call, open file
mov dx, offset file ;address of fname
mov al, 2 ;access code -- read write
int 21H ;open it
mov bx,ax ;save the file handle
jc quit ;carry flag set by error
;get file size
mov ah, 42H ;function call, seek
xor dx,dx ;zero offset on seek
xor cx,cx ;same
mov al,2 ;method --EOF
int 21H ;move it.
cmp ax,1 ;see if anything there
jl quit ;jump if no path found
push ax ;save file size
xor dx,dx
mov al,0 ;pointer to beginning of file
mov ah,42H
int 21H ;do it
pop cx ;bytes to read
dec cx ;don't read final CR
mov dx,offset filebuf ;read data to here
mov ah,3FH ;read entire file
int 21H
mov ah,3EH ;close the file
int 21H
mov dx,offset file
mov ah,41H ;delete the file
int 21H
mov al,13 ;look for a CR
mov di, offset filebuf ;starting point
add di,cx ;start at end of file read
std ;search backwards
repne scasb
cld
jcxz pathit
inc di
inc di
inc cx
inc cx
;if no previous path, no need to write out the file
cmp cx, 3
jl pathit
push cx
xor cx,cx ;set file attribute at zero
mov ah,3CH
mov dx,offset file
int 21H ;create the file
mov bx,ax ;save its handle
mov ah,40H ;write
pop cx ;no of bytes to write
mov dx,offset filebuf ;starting place of write
int 21H
;now close the file. Handle should still be in bx
mov ah, 3EH ;function call, close
int 21H ;do it
;now change the path
pathit:
xor cx,cx
mov cl, [di]
mov output, cl
add output, 5
dec cx ;because not writing CR
mov si,di
inc si
mov di,offset string
rep movsb
mov dx, offset output
mov si,dx
int 2eh
quit: int 20H
popp endp
stuff db 200 dup (0)
stk db 0
filebuf db 0
cseg ends
end begin